package Opera;

import BOOK.Book;
import BOOK.Booklist;

import java.util.Scanner;

public class ReturnOperation implements IOPeration{
    @Override
    public void work(Booklist booklist) {
        System.out.println("归还图书");
        System.out.println("输出你要归还的图书：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int currentSize = booklist.getUsedSize();
        for (int i = 0;i < currentSize; i++){
            Book book = booklist.getBook(i);
            if (book.getName().equals(name) && book.isBorrowed() == true){
                book.setBorrowed(false);
                System.out.println("归还成功");
                return;
            }
        }
    }
}
